#!/usr/bin/perl

#

package main;
Foo->add_trigger(before_foo => sub{print "sub1\n";});
Foo->add_trigger(after_foo => sub{print "aaaaa\n"});

my $foo = Foo->new;
$foo->foo;            # then sub1, sub2 called

package Foo;
use Class::Trigger;

sub new {
     my $class = shift;
     bless{},$class;
}

sub foo {
    my $self = shift;
    $self->call_trigger('before_foo');
    # some code ...
    $self->call_trigger('middle_of_foo');
    # some code ...
    $self->call_trigger('after_foo');
}



